package com.hospital.phyexam.controller;

import com.alibaba.fastjson.JSONObject;
import com.hospital.phyexam.service.ResaultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: Hospital
 * @description: 结果controller
 * @author: 杨曼珍
 * @create: 2019-01-13 20:50
 **/
@Controller
@RequestMapping(value = "/result")
public class ResaultController {
    @Autowired
    ResaultService resaultService;

    @RequestMapping(value = "/all", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    @ResponseBody
    public String getResault() {
        return resaultService.getAllResault();
    }

    @RequestMapping(value = "/batch", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String getByBatch(@RequestBody String data) {
        Integer phyExmBatchId=Integer.parseInt(JSONObject.parseObject(data).getString("phyExmBatchId"));
        return resaultService.selectByBatch(phyExmBatchId);
    }
    @RequestMapping(value = "/department", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String getBydepartment(@RequestBody String data) {
        Integer deptId=Integer.parseInt(JSONObject.parseObject(data).getString("deptId"));
        return resaultService.selectByDepartment(deptId);
    }
    @RequestMapping(value = "/project", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String getByproject(@RequestBody String data) {
        Integer proId=Integer.parseInt(JSONObject.parseObject(data).getString("proId"));
        return resaultService.selectByPro(proId);
    }
    @RequestMapping(value = "/update", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String update(@RequestBody String data) {
        Integer id=Integer.parseInt(JSONObject.parseObject(data).getString("id"));
        String conclusion=JSONObject.parseObject(data).getString("phyExmConclusion");
        return resaultService.update(id,conclusion);
    }@RequestMapping(value = "/delete", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String delete(@RequestBody String data) {
        Integer id=Integer.parseInt(JSONObject.parseObject(data).getString("id"));
        return resaultService.delete(id);
    }

}
